package org.myontology.controller.impl;

import org.apache.log4j.Logger;
import org.myontology.controller.AbstractAction;
import org.myontology.controller.AttributeHolder;
import org.myontology.controller.AttributeLevel;
import org.myontology.controller.ValueHandler;
import org.myontology.controller.pages.BasicPage;
import org.openrdf.model.URI;

import controller.sesameDataConnector.AbstractDataConnector;

public class HistoryPreviewAction extends AbstractAction {

	public static final ValueHandler<URI> URI = new ValueHandler<URI>(AttributeLevel.REQUEST,HistoryPreviewAction.class);

	private Logger logger;
	
	public void execute(AttributeHolder attributes) throws Exception {
		String undo = attributes.getRequestParameter("undo");
		String element = attributes.getRequestParameter("element");
		String type = element.substring(0,element.indexOf('/'));
		String name = element.substring(element.indexOf('/')+1);
		
		logger.debug("historyPreview: "+type+" "+name);
		
		if (type.equals("Class")) {
			URI uri = AbstractDataConnector.getURI(element);
			URI.setValue(attributes, uri);
			BasicPage.setContent(attributes, "components/classcomponents/preview.jsp");
		}
	}

}
